import request from '@/utils/request'

// 知识库管理接口
export function getKnowledgeBases(params) {
  return request({
    url: '/dk/knowledge/bases',
    method: 'get',
    params,
  })
}

export function createKnowledgeBase(data) {
  return request({
    url: '/dk/knowledge/bases',
    method: 'post',
    data,
    headers: { 'Content-Type': 'application/x-www-form-urlencoded' },
  })
}

export function updateKnowledgeBase(baseId, data) {
  return request({
    url: `/dk/knowledge/bases/${baseId}`,
    method: 'put',
    data,
    headers: { 'Content-Type': 'application/x-www-form-urlencoded' },
  })
}

export function deleteKnowledgeBase(baseId) {
  return request({
    url: `/dk/knowledge/bases/${baseId}`,
    method: 'delete',
  })
}

// 知识条目管理接口
export function getKnowledgeItems(params) {
  return request({
    url: '/dk/knowledge/items',
    method: 'get',
    params,
  })
}

export function getKnowledgeItem(itemId) {
  return request({
    url: `/dk/knowledge/items/${itemId}`,
    method: 'get',
  })
}

export function createKnowledgeItem(data) {
  return request({
    url: '/dk/knowledge/items',
    method: 'post',
    data,
    headers: { 'Content-Type': 'application/x-www-form-urlencoded' },
  })
}

export function updateKnowledgeItem(itemId, data) {
  return request({
    url: `/dk/knowledge/items/${itemId}`,
    method: 'put',
    data,
    headers: { 'Content-Type': 'application/x-www-form-urlencoded' },
  })
}

export function deleteKnowledgeItem(itemId) {
  return request({
    url: `/dk/knowledge/items/${itemId}`,
    method: 'delete',
  })
}
